package se.joakimback.decorator.view;

import java.awt.image.BufferedImage;
import java.util.LinkedList;
import java.util.List;

import se.joakimback.decorator.model.Layer;

public class Workspace {
	private static Workspace sSINGLETON = new Workspace();
	
	public static Workspace getSingleton() {
		return sSINGLETON;
	}
	
	private BufferedImage mBaseImage;
	
	private List<Layer> mLayers;
	
	private Layer mSelectedLayer;
	
	private List<LayerSelectionListener> mListeners;
	
	protected Workspace() {
		mListeners = new LinkedList<LayerSelectionListener>();
	}
	
	public void addListener(LayerSelectionListener pListener) {
		mListeners.add(pListener);
	}
	
	public void setSelectedLayer(Layer pLayer) {
		mSelectedLayer = pLayer;
		
		for (LayerSelectionListener vListener: mListeners) {
			vListener.layerSelected(mSelectedLayer);
		}
	}

	public BufferedImage getBaseImage() {
		return mBaseImage;
	}

	public void setBaseImage(BufferedImage baseImage) {
		mBaseImage = baseImage;
	}

	public List<Layer> getLayers() {
		return mLayers;
	}

	public void setLayers(List<Layer> layers) {
		mLayers = layers;
	}
}